package com.atguigu.gmall.web.all.controller;


import com.atguigu.gmall.feign.product.CategoryFeignClient;
import com.atguigu.gmall.model.vo.IndexCategoryVo;
import com.atguigu.gmall.web.all.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class IndexController {


    @Autowired
    IndexService indexService;

    @GetMapping({"/","/index.html"})
    public String index(Model model){

        //调用商品远程服务查询
        int i = 1;
        List<IndexCategoryVo> indexCategory = indexService.getIndexCategory();
        for (IndexCategoryVo categoryVo : indexCategory) {
            categoryVo.setIndex(i++);
        }

        model.addAttribute("list",indexCategory);
        return "index/index";
    }

}
